package com.breakfast.fun.common;

import android.content.Context;

import com.breakfast.fun.dao.ProductCartDao;
import com.breakfast.fun.event.CartEvent;
import com.breakfast.fun.util.DaoUtil;

import org.greenrobot.greendao.query.QueryBuilder;

/**
 * 购物车及商品代码公共类
 * Created by yukai on 2016/11/3.
 */

public class CommonCart {
    //本地购物车DAO
    public ProductCartDao productCartDao;
    //sql语句类
    public QueryBuilder qb;

    //购物车商品总数
    public int totalNum = 0;
    //购物车商品总价
    public double totalPrice = 0;
    //购物车事件，主要是用来更新商品数量和商品价格
    public CartEvent event;

    private Context mContext;

    /**
     * 初始化参数
     */
    public void init(Context context) {
        mContext = context;

        event = new CartEvent();

        productCartDao = DaoUtil.getProductCartDao();
        qb = productCartDao.queryBuilder();
        qb.LOG_SQL = true;
        qb.LOG_VALUES = true;

        totalNum = 0;
        totalPrice = 0;
    }
}
